package logic

import (
	"DataSrv/data"
	"DataSrv/global/model"
	"DataSrv/internal/svc"
	"context"

	"github.com/zeromicro/go-zero/core/logx"
)

type TypeAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewTypeAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TypeAddLogic {
	return &TypeAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *TypeAddLogic) TypeAdd(in *data.TypeAddRequest) (*data.TypeAddResponse, error) {
	// todo: add your logic here and delete this line
	var Type = model.Type{
		Name: in.Name,
		Pid:  int(in.Pid),
	}
	if err := model.DB.Create(&Type).Error; err != nil {
		return nil, err
	}
	return &data.TypeAddResponse{}, nil
}
